<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>腾讯商品列表</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
<#include "../template/include/assign.ftl">
<#include "../template/include/source.ftl">
<#include "../template/template_listPage.ftl">
    <link href="${web_static}/admin/css/list.css" rel="stylesheet" type="text/css"/>
    <style type="text/css">
        .page {
            float: right;
            padding-top: 15px;
            margin-right: 15px;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            var $validateErrorContainer = $("#validateErrorContainer");
            var $validateErrorLabelContainer = $("#validateErrorContainer ul");
            var $validateForm = $("#inputForm");
            var $tab = $("#tab");
            // Tab效果
            $tab.tabs(".tabContent", {
                tabs:"input"
            });

            // 表单验证
            $validateForm.validate({
                errorContainer:$validateErrorContainer,
                errorLabelContainer:$validateErrorLabelContainer,
                wrapper:"li",
                errorClass:"validateError",
                ignoreTitle:true,
                rules:{
                    "priceRatio":{
                        required:true
                    }
                },
                messages:{
                    "priceRatio":{
                        required:"请输入价格利率,只能输入数字!!!"
                    }
                },
                submitHandler:function (form) {
                    //$(form).find(":submit").attr("disabled", true);
                    form.submit();
                }
            });


            $('#searchButton').click(
                    function () {
                        $('#currentPage_listForm').val('1');
                    }
            );

            $('#isAudit').val('<#if tencentQuery??>${(tencentQuery.isAudit)!}</#if>');

        <#if actionErrors??&&(actionErrors?size > 0)>
            $.dialog({type: "warn", content: "<#list errorMessages as list>${list}<br></#list>",
                modal: true, autoCloseTime: 3000});
        </#if>
        });
        
        
        //获取校验码
        function getExtraCode(){
	    	 var loginAccount = $('#loginAccount').val();
	    	 if(loginAccount.length == 0){
	    	 	alert("获取验证码时，请输入登录账号！");
	    	 	return false;
	    	 }
	      	 var url = "${web_base}/game/tencent!obtainExtraCode.htm?" + "loginAccount=" + loginAccount;;
	         document.forms[0].action = encodeURI(url);
	         document.forms[0].submit();
     	 }  
        
        //登录
        function login(){
        	var loginAccount = $('#loginAccount').val();
        	var password = $('#password').val();
        	var extraCode = $('#extraCode').val();
        	if(loginAccount.length == 0){
	    	 	alert("请输入登录账号！");
	    	 	return false;
    		 }
    		 if(password.length == 0){
	    	 	alert("请输入登录密码！");
	    	 	return false;
    		 }
    		 if(extraCode.length == 0){
	    	 	alert("请输入获取的验证码！");
	    	 	return false;
    		 }
    		 if(extraCode.length > 4){
	    	 	alert("附加码的长度必须为4位！");
	    	 	return false;
    		 }
        	var pwd = password;
			var str = "";
			str = extraCode;    //===================验证码
			var key="aR!@$34GP<S#@Js;";
			var passwordKey = md5(str + hex_hmac_md5(key, pwd));
        	
        	var url = "${web_base}/game/tencent!testLogin.htm?passwordKey=" + passwordKey + "&extraCode=" + extraCode + "&loginAccount=" + loginAccount;
        	document.forms[0].action = encodeURI(url);
            document.forms[0].submit();
        }
        
//===================== 腾讯密码加密规则 ========================
	var hexcase = 1;
	var b64pad = "";
	var chrsz = 8;
	var mode = 32;
	
	function preprocess(form)
	{
	  var str = "";
	  str += form.verifycode.value;
	  str = str.toUpperCase();
	  form.p.value = md5(md5_3(form.p.value)+str);
	  return true;
	}
	function qbasprocess(form)
	{
	  var str = "";
	  str += form.ExtraCode.value;
	  str = str.toUpperCase();
	  var key="aR!@$34GP<S#@Js;";
	  form.Passwd.value = hex_hmac_md5(str, hex_hmac_md5 (key, form.Passwd.value));
	  return true;
	
	}
	
	function md5_3(s)
	{
	  var tmp = new Array;
	  tmp = core_md5(str2binl(s), s.length * chrsz);
	  tmp = core_md5(tmp, 16 * chrsz);
	  tmp = core_md5(tmp, 16 * chrsz);
	  return binl2hex(tmp);
	}
	
	function md5(s)
	{
	  return hex_md5(s);
	}
	function hex_md5(s)
	{
	  return binl2hex(core_md5(str2binl(s), s.length * chrsz));
	}
	
	function b64_md5(s)
	{
	  return binl2b64(core_md5(str2binl(s), s.length * chrsz));
	}
	
	function str_md5(s)
	{
	  return binl2str(core_md5(str2binl(s), s.length * chrsz));
	}
	
	function hex_hmac_md5(key, data)
	{
	  return binl2hex(core_hmac_md5(key, data));
	}
	
	function b64_hmac_md5(key, data)
	{
	  return binl2b64(core_hmac_md5(key, data));
	}
	
	function str_hmac_md5(key, data)
	{
	  return binl2str(core_hmac_md5(key, data));
	}
	
	function md5_vm_test()
	{
	  return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
	}
	
	function core_md5(x, len)
	{
	  x[len >> 5] |= 0x80 << ((len) % 32);
	  x[(((len + 64) >>> 9) << 4) + 14] = len;
	
	  var a = 1732584193;
	  var b =  - 271733879;
	  var c =  - 1732584194;
	  var d = 271733878;
	
	  for (var i = 0; i < x.length; i += 16)
	  {
	    var olda = a;
	    var oldb = b;
	    var oldc = c;
	    var oldd = d;
	
	    a = md5_ff(a, b, c, d, x[i + 0], 7,  - 680876936);
	    d = md5_ff(d, a, b, c, x[i + 1], 12,  - 389564586);
	    c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
	    b = md5_ff(b, c, d, a, x[i + 3], 22,  - 1044525330);
	    a = md5_ff(a, b, c, d, x[i + 4], 7,  - 176418897);
	    d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
	    c = md5_ff(c, d, a, b, x[i + 6], 17,  - 1473231341);
	    b = md5_ff(b, c, d, a, x[i + 7], 22,  - 45705983);
	    a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
	    d = md5_ff(d, a, b, c, x[i + 9], 12,  - 1958414417);
	    c = md5_ff(c, d, a, b, x[i + 10], 17,  - 42063);
	    b = md5_ff(b, c, d, a, x[i + 11], 22,  - 1990404162);
	    a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
	    d = md5_ff(d, a, b, c, x[i + 13], 12,  - 40341101);
	    c = md5_ff(c, d, a, b, x[i + 14], 17,  - 1502002290);
	    b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
	
	    a = md5_gg(a, b, c, d, x[i + 1], 5,  - 165796510);
	    d = md5_gg(d, a, b, c, x[i + 6], 9,  - 1069501632);
	    c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
	    b = md5_gg(b, c, d, a, x[i + 0], 20,  - 373897302);
	    a = md5_gg(a, b, c, d, x[i + 5], 5,  - 701558691);
	    d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
	    c = md5_gg(c, d, a, b, x[i + 15], 14,  - 660478335);
	    b = md5_gg(b, c, d, a, x[i + 4], 20,  - 405537848);
	    a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
	    d = md5_gg(d, a, b, c, x[i + 14], 9,  - 1019803690);
	    c = md5_gg(c, d, a, b, x[i + 3], 14,  - 187363961);
	    b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
	    a = md5_gg(a, b, c, d, x[i + 13], 5,  - 1444681467);
	    d = md5_gg(d, a, b, c, x[i + 2], 9,  - 51403784);
	    c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
	    b = md5_gg(b, c, d, a, x[i + 12], 20,  - 1926607734);
	
	    a = md5_hh(a, b, c, d, x[i + 5], 4,  - 378558);
	    d = md5_hh(d, a, b, c, x[i + 8], 11,  - 2022574463);
	    c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
	    b = md5_hh(b, c, d, a, x[i + 14], 23,  - 35309556);
	    a = md5_hh(a, b, c, d, x[i + 1], 4,  - 1530992060);
	    d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
	    c = md5_hh(c, d, a, b, x[i + 7], 16,  - 155497632);
	    b = md5_hh(b, c, d, a, x[i + 10], 23,  - 1094730640);
	    a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
	    d = md5_hh(d, a, b, c, x[i + 0], 11,  - 358537222);
	    c = md5_hh(c, d, a, b, x[i + 3], 16,  - 722521979);
	    b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
	    a = md5_hh(a, b, c, d, x[i + 9], 4,  - 640364487);
	    d = md5_hh(d, a, b, c, x[i + 12], 11,  - 421815835);
	    c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
	    b = md5_hh(b, c, d, a, x[i + 2], 23,  - 995338651);
	
	    a = md5_ii(a, b, c, d, x[i + 0], 6,  - 198630844);
	    d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
	    c = md5_ii(c, d, a, b, x[i + 14], 15,  - 1416354905);
	    b = md5_ii(b, c, d, a, x[i + 5], 21,  - 57434055);
	    a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
	    d = md5_ii(d, a, b, c, x[i + 3], 10,  - 1894986606);
	    c = md5_ii(c, d, a, b, x[i + 10], 15,  - 1051523);
	    b = md5_ii(b, c, d, a, x[i + 1], 21,  - 2054922799);
	    a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
	    d = md5_ii(d, a, b, c, x[i + 15], 10,  - 30611744);
	    c = md5_ii(c, d, a, b, x[i + 6], 15,  - 1560198380);
	    b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
	    a = md5_ii(a, b, c, d, x[i + 4], 6,  - 145523070);
	    d = md5_ii(d, a, b, c, x[i + 11], 10,  - 1120210379);
	    c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
	    b = md5_ii(b, c, d, a, x[i + 9], 21,  - 343485551);
	
	    a = safe_add(a, olda);
	    b = safe_add(b, oldb);
	    c = safe_add(c, oldc);
	    d = safe_add(d, oldd);
	  }
	  if (mode == 16)
	  {
	    return Array(b, c);
	  }
	  else
	  {
	    return Array(a, b, c, d);
	  }
	}
	
	function md5_cmn(q, a, b, x, s, t)
	{
	  return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
	}
	
	function md5_ff(a, b, c, d, x, s, t)
	{
	  return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
	}
	
	function md5_gg(a, b, c, d, x, s, t)
	{
	  return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
	}
	
	function md5_hh(a, b, c, d, x, s, t)
	{
	  return md5_cmn(b ^ c ^ d, a, b, x, s, t);
	}
	
	function md5_ii(a, b, c, d, x, s, t)
	{
	  return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
	}
	
	function core_hmac_md5(key, data)
	{
	  var bkey = str2binl(key);
	  if (bkey.length > 16)
	    bkey = core_md5(bkey, key.length * chrsz);
	
	  var ipad = Array(16), opad = Array(16);
	  for (var i = 0; i < 16; i++)
	  {
	    ipad[i] = bkey[i] ^ 0x36363636;
	    opad[i] = bkey[i] ^ 0x5C5C5C5C;
	  }
	
	  var hash = core_md5(ipad.concat(str2binl(data)), 512+data.length * chrsz);
	  return core_md5(opad.concat(hash), 512+128);
	}
	
	function safe_add(x, y)
	{
	  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
	  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
	  return (msw << 16) | (lsw & 0xFFFF);
	}
	
	function bit_rol(num, cnt)
	{
	  return (num << cnt) | (num  >>> (32-cnt));
	}
	
	function str2binl(str)
	{
	  var bin = Array();
	  var mask = (1 << chrsz) - 1;
	  for (var i = 0; i < str.length * chrsz; i += chrsz)
	    bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32);
	  return bin;
	}
	
	function binl2str(bin)
	{
	  var str = "";
	  var mask = (1 << chrsz) - 1;
	  for (var i = 0; i < bin.length * 32; i += chrsz)
	    str += String.fromCharCode((bin[i >> 5] >>> (i % 32)) & mask);
	  return str;
	}
	
	function binl2hex(binarray)
	{
	  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
	  var str = "";
	
	  for (var i = 0; i < binarray.length * 4; i++)
	  {
	    str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8+4)) & 0xF) +
	      hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF);
	  }
	  return str;
	}
	
	function binl2b64(binarray)
	{
	  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
	  var str = "";
	  for (var i = 0; i < binarray.length * 4; i += 3)
	  {
	    var triplet = (((binarray[i >> 2] >> 8 * (i % 4)) & 0xFF) << 16) | ((
	      (binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8) | ((binarray[i
	      + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF);
	    for (var j = 0; j < 4; j++)
	    {
	      if (i * 8+j * 6 > binarray.length * 32)
	        str += b64pad;
	      else
	        str += tab.charAt((triplet >> 6 * (3-j)) & 0x3F);
	    }
	  }
	  return str;
	}      
        

</script>
</head>
<body class="list">
<div class="body">
    <div class="listBar">
        <h1><span class="icon">&nbsp;</span>腾讯商品管理&nbsp;<span class="pageInfo"></span></h1>
    </div>
    <div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
        <div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
        <ul></ul>
    </div>
    
    <#--*********** 腾讯官网账号登录  ***********-->
    <br>
   	 登录账号：<input type="text" id="loginAccount" value="${loginAccount!}"/>
    	&nbsp;&nbsp;&nbsp;&nbsp;
    	密码：<input type="password" id="password" value=""/>
    	&nbsp;&nbsp;&nbsp;&nbsp;
    	验证码：<input type="text" id="extraCode" value=""/>
    	&nbsp;
    	<span class="spanLink" onclick="getExtraCode();" title="">
    		<img src='${web_base}/extraCode/${fileName!}' alt='${fileName!}' >
    	</span>
    	&nbsp;
    	<span class="spanLink" onclick="getExtraCode();" title="">[获取验证码]</span>
    	<span id="orderSpan" style="color: red;">注：获取验证码时，请输入登录账号</span>
    	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    	 <br> 
         <span class="spanLink" onclick="login();" title="腾讯登录加密">[腾讯登录]</span>
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         	登录结果：<span id="orderSpan" style="color: red;">${loginResult!}</span>
         <br> <br> <br>
    	
    
    
    
    
    <form id="inputForm" class="validate" action="${web_base}/game/tencent!audit.htm" method="post">
        <div class="operateBar">
            <label>请输入价格利率：</label>
            <input type="text" name="priceRatio"  value="" onkeyup="this.value=this.value.replace(/\D/g,'')"
                   onafterpaste="this.value=this.value.replace(/\D/g,'')"/>‰
            <input type="hidden" name="supplierId" value="20121002">
            <input type="submit"  class="addButton" value="批量审核"/>
            <input type="button" class="addButton" onclick="location.href='${web_base}/game/tencent!add.htm'" value="商品添加" />
        </div>
    </form>
<@pageList page=(page!) id="listForm" action="${web_base}/game/tencent!list.htm" query="tencentQuery" isEmpty=true>
    <div class="operateBar">

        <label>查找:</label>
        产品名称：&nbsp;&nbsp;<input type="text" name="tencentQuery.productName"
                    value="<#if tencentQuery??>${(tencentQuery.productName)!}</#if>"/>
        产品编号：<input type="text" name="tencentQuery.goodsId"
                    value="<#if tencentQuery??>${(tencentQuery.goodsId)!}</#if>"/>
        是否审核：<select name="tencentQuery.isAudit" id="isAudit">
        <option value="" selected="selected">请选择...</option>
        <option value="1">
            已审核
        </option>
        <option value="0">
            未审核
        </option>
    </select>
        <input type="submit" id="searchButton" class="searchButton" value=""/>
    </div>
    <table class="listTable">
        <tr>
            <th>
                <span name="productName">产品名称</span>
            </th>
            <th>
                <span name="goodsId">产品编号</span>
            </th>
            <th>
                <span name="inPrice">产品进价(元)</span>
            </th>
            <#--<th>-->
                <#--<span name="rechargeMode">充值方式</span>-->
            <#--</th>-->
            <th>
                <span name="in_acct_type">用户帐号类型</span>
            </th>
            <th>
                <span name="sell_type">服务类型</span>
            </th>
            <th>
                <span name="sell_sub_type">服务子类型</span>
            </th>
            <th>
                <span name="num">充值数量</span>
            </th>
            <th>
                <span name="isAudit">审核状态</span>
            </th>
            <th>操&nbsp;作
            <th/>
        </tr>

        <#if page?? && page.list?? && (page.list?size gt 0)>
            <#list page.list as obj>
                <tr>
                    <td>
                        <#if obj.productName?? && obj.productName?length gte 15>
                        <#--//截取输出文字的长度-->
                        ${obj.productName?substring(0,15)}...
                        <#else>
                        ${(obj.productName)!}
                        </#if>
                    </td>
                    <td>
                         ${(obj.goodsId)!}
                    </td>
                    <td>
                         ${(obj.inPrice)!}
                    </td>
                    <#--<td>-->
                        <#--<#if obj.rechargeMode?? && obj.rechargeMode=="2">-->
                            <#--直充-->
                        <#--<#elseif obj.rechargeMode?? && obj.rechargeMode=="1">-->
                            <#--卡充-->
                        <#--</#if>-->
                    <#--</td>-->
                    <td>
                        ${(obj.in_acct_type)!}
                    </td>
                    <td>
                        ${(obj.sell_type)!}
                    </td>
                    <td>
                        ${(obj.sell_sub_type)!}
                    </td>
                    <td>
                        ${(obj.num)!}
                    </td>
                    <td>
                        <#if obj.isAudit?? && obj.isAudit=="0">
                            未审核
                        <#elseif obj.isAudit?? && obj.isAudit=="1">
                            已审核
                        </#if>
                    </td>
                    <td>
                        <#--<#if obj.isAudit?? && obj.isAudit=="0">-->
                            <#--<a href="${web_base}/game/audit!list.htm?originalGoodsId=${(obj.goodsId)!}&supplyId=20121002" title="审核">[审核]</a>&nbsp;&nbsp;&nbsp;-->
                        <#--<#elseif obj.isAudit?? && obj.isAudit=="1">-->
                            <#--[已审核]-->
                        <#--</#if>-->
                        <a href="${web_base}/game/tencent!toEdit.htm?goodsId=${(obj.goodsId)!}" title="编辑">[编辑]</a>
                    </td>
                </tr>
            </#list>
        </#if>
    </table>

    <#if page?? && page.list?? && (page.list?size <= 0)>
        <div class="noRecord">
            没有找到任何记录!
        </div>
    </#if>
</@pageList>
</div>

</body>
</html>